package com.seeyon.apps.bense.bank.core;

import com.seeyon.ctp.common.AppContext;
import com.seeyon.ctp.util.Strings;

public class Constants {

    // 单商户应用key
    public static final String appKey = getSystemProperty("bank.base.app_key", "54b3e05c-7983-4e6c-8920-f9ab8a0004a6");
    // 单商户开放平台地址
    public static final String publicUrl = getSystemProperty("bank.base.public_url", "http://cz-test.nbcb.com.cn:7070/nbcb/api");
    // 单商户开放平台公钥
    public static final String publicKey = getSystemProperty("bank.base.public_key", "MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAEXAt6fxeKlpREIyXoT3jDwGU7L6JkKrzdOKP1cMB14rtNwwlyaUGLrtuHVoArAHP3x7XN2rUw0GxSngYQwOAsjQ==");
    // 单商户开放平台私钥
    public static final String privateKey = getSystemProperty("bank.base.private_key",
            "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgTt6OadouxxxSDg/0SZdOIBqtnFGKrpwmL+quEUf+hfSgCgYIKoEcz1UBgi2hRANCAAQGHNN2NO7btp+w1248yk98E0asGC8sG0bmIzdom4M0xp3vc4IfXjmZ8omUz4oVcjzAuyMSSpJM6uPLcU1SH4HZ");
    // 财资客户号
    public static final String custId = getSystemProperty("bank.base.cust_id", "");
    // 连接超时时间
    public static final String connectTimeout = getSystemProperty("bank.base.connect_timeout", "60000");
    // 读取超时时间
    public static final String readTimeout = getSystemProperty("bank.base.read_timeout", "60000");

    public static final String test_cron = getSystemProperty("bank.cron.test", "");

    // 费用报销表单编号
    public static final String paymentTab = getSystemProperty("bank.form.paymentTab", "");
    // 付款申请表单编号
    public static final String paymentApplyTab = getSystemProperty("bank.form.paymentApplyTab", "");
    // 内部调拨表单编号
    public static final String internalTransferTab = getSystemProperty("bank.form.internalTransferTab", "");
    // 专款专用表单编号
    public static final String purposeFundsTab = getSystemProperty("bank.form.purposeFundsTab", "");
    // 差旅费报销表单编号
    public static final String travelPaymentTab = getSystemProperty("bank.form.travelPaymentTab", "");
    // 银行账号配置表
    public static final String bankAccTab = getSystemProperty("bank.form.bankAccTab", "");

    public static final String travelPaymentCron = getSystemProperty("bank.cron.travelPayment", "");

    public static final String paymentCron = getSystemProperty("bank.cron.payment", "");

    public static final String paymentApplyCron = getSystemProperty("bank.cron.paymentApply", "");

    /**
     * 获取系统属性值
     *
     * @param key          配置键
     * @param defaultValue 默认值
     * @return 配置值
     */
    private static String getSystemProperty(String key, String defaultValue) {
        try {
            String value = AppContext.getSystemProperty(key);
            return Strings.isNotBlank(value) ? value : defaultValue;
        } catch (Exception e) {
            return defaultValue;
        }
    }
}
